package com.shujia.scala

import scala.io.Source

object Demo25implicit {
  def main(args: Array[String]): Unit = {

    /**
      * 隐式转换类
      *
      */


    val lines: List[String] = "scala/data/students.txt".read()

    lines.foreach(println)

    val words: List[String] = "scala/data/words.txt".read()

    words.foreach(println)


  }

  /**
    * 隐式转换类
    *
    * 可以将ReadFile构造函数参数的类型转换成ReadFile
    *
    *
    */
  implicit class ReadFile(path: String) {

    def read() = {
      Source.fromFile(path).getLines().toList
    }

  }

}
